﻿using System;
using System.Collections.Generic;
using System.Text;

class MultiverseCommunication
    {
        static void Main(string[] args)
        {

            string input = Console.ReadLine().ToUpper();
            List<string> numbers = new List<string>();
            int count = 2;
            string number = "";

            for (int i = 0; i < input.Length; i++)
            {
                number += input[i];
                if (i == count)
                {
                    numbers.Add(number);
                    count += 3;
                    number = "";
                }

            }
            double result = ConvertToDecimal(numbers.ToArray());
            Console.WriteLine(result);
        }
    
    static double ConvertToDecimal (string[] code)
        {

            double result = 0;
            for (int i = 0; i < code.Length; i++)
            {
                switch (code[i])
                {
                    case "CHU": result += 0 * Math.Pow(13, code.Length - 1 - i); break;
                    case "TEL": result += 1 * Math.Pow(13, code.Length - 1 - i); break;
                    case "OFT": result += 2 * Math.Pow(13, code.Length - 1 - i); break;
                    case "IVA": result += 3 * Math.Pow(13, code.Length - 1 - i); break;
                    case "EMY": result += 4 * Math.Pow(13, code.Length - 1 - i); break;
                    case "VNB": result += 5 * Math.Pow(13, code.Length - 1 - i); break;
                    case "POQ": result += 6 * Math.Pow(13, code.Length - 1 - i); break;
                    case "ERI": result += 7 * Math.Pow(13, code.Length - 1 - i); break;
                    case "CAD": result += 8 * Math.Pow(13, code.Length - 1 - i); break;
                    case "K-A": result += 9 * Math.Pow(13, code.Length - 1 - i); break;
                    case "IIA": result += 10 * Math.Pow(13, code.Length - 1 - i); break;
                    case "YLO": result += 11 * Math.Pow(13, code.Length - 1 - i); break;
                    case "PLA": result += 12 * Math.Pow(13, code.Length - 1 - i); break;

                }

            }
            return result;

        }



}

